package org.example.crazy.controller;

import org.example.crazy.domain.User;
import org.example.crazy.service.IDemoService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

/**
 * @Author yzz
 * @CreateTime 2025/03/11
 * @Description DemoApplication
 */
@RestController
public class DemoController {

    @Resource
    private IDemoService service;

    @GetMapping("/test")
    public String getTest(){
        return "测试请求";
    }

    @GetMapping("/selectDB")
    public User sqlTest(){
        return service.getById("2547");
    }

    /**
     * dao层使用注解测试 foreach
     * @return List<User>
     */
    @GetMapping("/dao/annotation/foreach")
    public List<User> daoAnnotationTest(){
        return service.getUsersByDaoAnnotation(Collections.singletonList(2547));
    }

    /**
     * dao层使用xml测试 foreach
     * @return List<User>
     */
    @GetMapping("/dao/xml/foreach")
    public List<User> daoXmlTest(){
        return service.getUsersByDaoXml(Collections.singletonList(2547));
    }
}
